import React from 'react'
import Priority from 'components/template/priority'

export default {
  key: 'priority',
  name: 'Priority 权限',
  author: '张然',
  description: '选择系统设置权限需要的组件。',
  isExampleFull: true,
  api: [
    {
      title: 'API',
      data: [{
        param: 'formItemLayout', description: '内部表单组件的布局。', type: 'object', defaultValue: '{ labelCol: { span: 8 }, wrapperCol: { span: 10, offset: 1 }}'
      }, {
        param: 'top', description: '顶级层级，有::TENANT::、::SET_OF_BOOKS::、::COMPANY::三种。', type: 'string', defaultValue: '-'
      }, {
        param: 'onChange', description: '内部值有变化时的回调。', type: 'function(value)', defaultValue: '() => {}'
      }, {
        param: 'defaultValue', description: '默认值，::{ levelCode, levelOrgName, levelOrgId, distribution: { companies } }::。', type: 'object', defaultValue: '-'
      }, {
        param: 'companyComponent', description: '公司组件，有::Chooser::与::Searcher::两种。', type: 'string', default: 'Chooser'
      }, {
        param: 'companyProps', description: '公司组件的::props::，会覆盖内部默认。', type: 'object', default: '{}'
      }, {
        param: 'getSetOfBooksCompanyParams', description: '当范围选择了账套时，获取公司组件::listExtraParams::时的方法。', type: 'function(setOfBooksId)', defaultValue: 'setOfBooksId => ({ setOfBooksId })'
      }, {
        param: 'onlyTenant', description: '是否切换至仅选择租户的模式，同时::onChange::返回值和::defaultValue::结构会变成::{range, rangeValue}::形式。', type: 'boolean', defaultValue: '-'
      }, {
        param: 'onlySetOfBooks', description: '是否切换至仅选择账套的模式，同时::onChange::返回值和::defaultValue::结构会变成::{range, rangeValue}::形式。', type: 'boolean', defaultValue: '-'
      }, {
        param: 'onlyCompany', description: '是否切换至仅选择公司的模式，同时::onChange::返回值和::defaultValue::结构会变成::{range, rangeValue}::形式。', type: 'boolean', defaultValue: '-'
      }, {
        param: 'disabledTop', description: '是否禁用顶层层级。', type: 'boolean', defaultValue: '-'
      }, {
        param: 'showCompany', description: '是否在顶层显示公司层级选项。', type: 'boolean', defaultValue: 'true'
      }, {
        param: 'showCompanyComponent', description: '是否显示公司层级组件。', type: 'boolean', defaultValue: 'true'
      }, {
        param: 'onChangeRange', description: '当所属组织变化时的回调，返回改变的组织对象。', type: 'function(value)', defaultValue: '() => {}'
      }, {
        param: 'required', description: '是否显示必填的红色星号。', type: 'boolean', defaultValue: '-'
      }],
      description: ''
    }
  ],
  example: [
    {
      title: '基础用法',
      description: '',
      state: {
        annotateList: []
      },
      getMethod: context => {
        return {

        }
      },
      getContent: context => {
        return (
          <div>
            <Priority top='TENANT' onChange={console.log}/>
            <br />
            <Priority top='SET_OF_BOOK' onChange={console.log}/>
            <br />
            <Priority top='COMPANY' onChange={console.log}/>
          </div>
        )
      }
    },
    {
      title: '默认值',
      description: '',
      state: {
        annotateList: []
      },
      getMethod: context => {
        return {

        }
      },
      getContent: context => {
        return (
          <div>
            <Priority top='TENANT' defaultValue={{
              levelCode: 'COMPANY',
              levelOrgId: '123',
              levelOrgName: '默认值里的公司',
              distribution: {
                companies: []
              }
            }}/>
            <br />
            <Priority top='TENANT' defaultValue={{
              levelCode: 'TENANT',
              levelOrgId: '123',
              levelOrgName: '默认值里的租户',
              distribution: {
                companies: []
              }
            }}/>
            <br />
            <Priority top='TENANT' defaultValue={{
              levelCode: 'TENANT',
              levelOrgId: '123',
              levelOrgName: '默认值里的租户',
              distribution: {
                companies: [{
                  name: '默认值里的公司',
                  id: '123'
                }]
              }
            }}/>
            <Priority top='TENANT' defaultValue={{
              levelCode: 'TENANT',
              levelOrgId: '123',
              levelOrgName: '默认值里的租户',
              distribution: {
                companies: [{
                  name: '默认值里的公司',
                  id: '123'
                }]
              }
            }} companyComponent='Searcher'/>
          </div>
        )
      }
    },
    {
      title: '仅选择租户、仅选择账套、仅选择公司',
      description: '设置::onlyTenant::可设置仅选择租户，设置::onlySetOfBooks::可设置仅选择账套，设置::onlyCompany::可设置仅选择公司。',
      state: {
        annotateList: []
      },
      getMethod: context => {
        return {

        }
      },
      getContent: context => {
        return (
          <div>
            <Priority onlyTenant onChange={console.log}/>
            <br />
            <Priority onlySetOfBooks onChange={console.log}/>
            <br />
            <Priority
              onlySetOfBooks
              onChange={console.log}
              defaultValue={{
                range: 'SET_OF_BOOK',
                rangeValue: [{
                  setOfBooksName: '默认值里的账套',
                  setOfBooksId: '123'
                }]
              }}
            />
            <br />
            <Priority onlyCompany onChange={console.log}/>
          </div>
        )
      }
    },
    {
      title: '特殊需求',
      description: '::showCompany::、::disabledTop::、::showCompanyComponent::。',
      state: {
        annotateList: []
      },
      getMethod: context => {
        return {

        }
      },
      getContent: context => {
        return (
          <div>
            <Priority top='SET_OF_BOOK' onChange={console.log} showCompany={false}/>
            <br />
            <Priority
              disabledTop
              onChange={console.log}
              top='TENANT'
              defaultValue={{
                levelCode: 'TENANT',
                levelOrgId: '123',
                levelOrgName: '默认值里的租户',
                distribution: {
                  companies: [{
                    name: '默认值里的公司',
                    id: '123'
                  }]
                }
              }}
            /><br/>
            <Priority top='SET_OF_BOOK' onChange={console.log} showCompanyComponent={false}/>
          </div>
        )
      }
    }
  ]
}
